import { MyRequest } from '../index'

import type { userListRoot, deparmentRoot } from '@/types/index'

// 请求用户列表
export function postUserListData(queryInfo: any) {
  return MyRequest.post<userListRoot>({
    url: '/users/list',
    data: queryInfo
  })
}
// 根据用户id删除数据
export function deleUserById(id: number) {
  return MyRequest.delete({ url: `users/${id}` })
}
// 创建用户
export function createUser(userInfo: any) {
  return MyRequest.post({
    url: '/users',
    data: userInfo
  })
}
// 修改用户
export function editUser(id: number, userInfo: any) {
  return MyRequest.patch({
    url: `users/${id}`,
    data: userInfo
  })
}

// 针对页面的网络请求
export function postPageListData(pageName: string, queryInfo: any) {
  return MyRequest.post<any>({
    url: `/${pageName}/list`,
    data: queryInfo
  })
}
export function deletePageDataById(pageName: string, id: number) {
  return MyRequest.delete({ url: `${pageName}/${id}` })
}
export function createPageListData(pageName: any, dataInfo: any) {
  return MyRequest.post({
    url: `/${pageName}`,
    data: dataInfo
  })
}
export function editPageListData(pageName: any, id: number, dataInfo: any) {
  return MyRequest.patch({
    url: `${pageName}/${id}`,
    data: dataInfo
  })
}
